package com.yanqu.road.server.cmd.wingroom.message;

import com.yanqu.road.pb.wingroom.WingRoomProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.wingroom.WingRoomMessageMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

/**
 * @author ：zfr
 * @date ：2022/3/19 21:47
 */
@Cmd(code = GameProtocol.S_WING_ROOM_CROSS_REQ_MESSAGE_BOARD, desc = "跨服来请求留言板")
public class CrossGetMessageBoardCmd implements Command {
    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        WingRoomProto.GetMessageBoardCrossReqMsg crossReqMsg = WingRoomProto.GetMessageBoardCrossReqMsg.parseFrom(packet.getBytes());
        long guestServerId = crossReqMsg.getGuestServerId();
        long guestUserId = crossReqMsg.getGuestUserId();
        boolean likeToday = crossReqMsg.getLikeToday();
        WingRoomProto.GetMessageAllDataRespMsg.Builder resp = WingRoomMessageMgr.getMessageAllDataResp(packet.getPlayerId(), guestUserId, likeToday);
        WingRoomProto.GetMessageBoardRespCrossMsg.Builder respCrossMsg = WingRoomProto.GetMessageBoardRespCrossMsg.newBuilder();
        respCrossMsg.setGuestServerId(guestServerId);
        respCrossMsg.setGuestUserId(guestUserId);
        respCrossMsg.setRespMsg(resp);
        YanQuMessage message = YanQuMessageUtils.buildMessage(CrossProtocol.C_WING_ROOM_GET_MESSAGE_BOARD_RESP, respCrossMsg);
        GamePlayerMgr.sendPacket(0, message);
    }
}
